package com.gms.service.equipmanager.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gms.entity.equipment.Equipmenttype;
import com.gms.mapper.EquipmenttypeMapper;
import com.gms.service.equipmanager.EquipmenttypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jianghai
 * @since 2021-06-14
 */
@Service
public class EquipmenttypeServiceImpl extends ServiceImpl<EquipmenttypeMapper, Equipmenttype> implements EquipmenttypeService {

    @Autowired
    private EquipmenttypeMapper mapper;

    @Override
    public Equipmenttype queryByName(String etypename) {
        QueryWrapper<Equipmenttype> wrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(etypename)) {
            wrapper.eq("etypename",etypename);
        }
        return mapper.selectOne(wrapper);
    }

    @Override
    public Page<Equipmenttype> query_equip(String etypename, Integer eTypeId, Integer pageNum) {
        Page<Equipmenttype> page = new Page<>(pageNum,5);

        QueryWrapper<Equipmenttype> wrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(etypename)) {
            wrapper.like("etypename",etypename);
        }
        if (!StringUtils.isEmpty(eTypeId)) {
            wrapper.like("eTypeId",eTypeId);
        }
        return mapper.selectPage(page,wrapper);
    }



}
